<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>练习</title>
    <style>
        #one{
            width: 30px;
            height: 30px;
            background-color: red;
        }
         #two{
            width: 30px;
            height: 30px;
            background-color:green;
        }
         #three{
            width: 30px;
            height: 30px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
    <script>
        var red = document.getElementById('one');
        var body = document.querySelector('body');
        red.onclick = function(){
            body.style.backgroundColor = 'red';
        }
        var green = document.getElementById('two');
        green.onclick = function(){
            body.style.backgroundColor = 'green';
        }
         var pink = document.getElementById('three');
        pink.onclick = function(){
            body.style.backgroundColor = 'pink';
        }


    </script>
</body>
</html>